home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-10-20 | 5.0 KB | 106 lines | [TEXT/GEOL] |
- Item forwarded by BURBECK.S to EYES
-
- Item 3714398 19-Oct-89 09:26
-
- From: PASCOE1 Pascoe, Geoff
-
- To: MACAPP.TECH$ MACAPP Tech
-
- Sub: Re: NeXT…
-
- NOTE: THE FOLLOWING REPRESENTS MY OWN OPINIONS AND NOT THAT OF APPLE
-
- Alan,
-
- The differences you see, for example, between Objective-C and Object Pascal is
- the direct result of three things:
-
- 1) Run-time representation of meta-data,
-
- 2) Run-time facilities for accessing and using that meta-data, and
-
- 3) The differences between strict and lenient (or no) type checking.
-
- To simplify matters, somewhat, one can view languages as a spectrum from those
- with little run-time support to those with a lot of run-time support. I
- illustrate as follows-
-
- Lots of runtime Smalltalk, LISP (comes in different O-O flavors)
- | |
- | Objective-C
- | |
- | Object Pascal
- | |
- Very little runtime C++
-
- Smalltalk and LISP provides lots of run-time support. Flexible and dynamic
- messaging, explicit representation of messages, meta-data, etc. For the most
- part, though, forget about static type checking (you might get some of this in
- some O-O versions of LISP- I'm not familiar with the newer O-O extensions to
- this language).
-
- Objective-C also has a reasonable amount of run-time support. It has a
- concrete representation of messages, some meta-data (not complete), but no GC.
- In the latest version of Objective-C (version 4.0) you also get optional
- typing.
-
- Object Pascal has very little meta-data. It does store an explicit structure
- for classes which has the class name and size of instances and retains some
- flexibility in it's messaging mechanism, although selectors don't have a useful
- concrete represenation. The type checking is pretty strict here.
-
- C++ tries to get rid of as much data as possible after compilation. Meta-data
- is NIL and messaging uses the less flexible, but slightly more efficient
- V-table approach- so forget about selectors, they don't exist. Type checking
- is strict, but you get lots of compile-time facilities like overloading.
-
- What is it about the 3 things above that make doing an interface-builder type
- of thing easier?
-
- First, you point out that since selectors have a concrete representation you
- can use a 'perform:' message to be very dynamic in sending messages. This is
- especially useful when dealing with user-interfaces. The more static languages
- will have to simulate this. Of course, you pay penalties:
-
- 1) Some storage overhead for selector representation,
-
- 2) Potentially lots of overhead for code, since you can't tell until
- run-time what message will be sent, you can't statically strip out
- methods that won't be used,
-
- 3) You give up type checking when you use 'perform:' (assuming you would
- normally have it). So, you can get run-time messaging errors.
-
- Second, the existence of meta-data allows you to 'store-out' the representation
- of an object automagically to file and read it back in later. If you have all
- objects (Smalltalk), you can use a recursive technique to tell all the objects
- to store themselves out. If you have a hybrid environment (Objective-C), those
- instance variables that aren't objects have type-information in the class, so
- you know just what to do. (Except in the world of C, where programmers don't
- expect things like structures or arrays to have meta-data, following anonymous
- pointers is definitely a problem. Theoretically, the full typing of lots of
- agregate types can be stored for instance variable in the class, including the
- types of pointers in fields of structures, etc. But currently, Objective-C
- doesn't deal with this well. So, you have to do some extra work and/or be very
- careful.) More static languages make the programmer reponsible for this kind
- of stuff (see, for example, TDocument.DoRead and TDocument.DoWrite). Also,
- classes as objects clearly helps here too.
-
- Third, lots of other things become easier, like inspectors and debuggers. If
- the meta-data is ALL there then you don't need a 'Fields' method hand-coded by
- the programmer. Interestingly, though, Objective-C's meta-data isn't complete.
- Classes have the types of instance variables but not their names, and selectors
- have their names available but not their types. Clearly a very significant
- oversight. If you're going to bite of the storage and performance penalty for
- doing this run-time stuff, you might as well make it complete.
-
- Incidentally, there is no reason why Object Pascal or C++ could not support
- meta-data and lots of other stuff, although consistently strict type-checking
- can get in the way. The semantics would change slightly, but most current
- programs (e.g., those that don't follow pointers and play bit-twiddling games
- with class structures) wouldn't be severely impacted. I believe that ET++
- already does some of this for C++.
-
- Geoff
-
-